<?php


/**
 * @author yaya
 * 新成员入群事件
 */
class ReceiveNewMemberAdd {
	private $message = "";
	private $auth = null;
	private $cp = null;
	function ReceiveNewMemberAdd() {
		$this->auth = new Authority();
		$this->cp = new ClusterParam();
	}

	public function run() {
		if ($this->auth->adminLevel > 1) {
			$this->message = "欢迎入裙，有个奇怪的人进来了  >_<~!";
			return;
		}
		$RECEIVENEWMEMBERADD_MESS = $this->cp->getParamValue('RECEIVENEWMEMBERADD_MESS');
		$this->message = preg_replace(array (
			"/\{0\}/",
			"/\{1\}/",
			"/\{2\}/",
			"/\{3\}/"
		), array (
			$_POST[Sender],
			$_POST[Nick],
			$_POST[ClusterName],
			$_POST[ClusterNum]
		), $RECEIVENEWMEMBERADD_MESS);
		$ret2 = @ DB :: GetQueryResult("select * from td_REMOVED_recode where  clusternum='{$_POST[ClusterNum]}' and qq='{$_POST[Sender]}' order by day", false);
		if (count($ret2) != 0) {
			$mess .= "\n\n检测到此人有退群或者被T记录：\n";
			foreach ($ret2 as $key => $v) {
				$mess .= "qq号码：{$v[qq]} \t在：{$v[day]}\t" . ($v[flag] == 1 ? "自己退出过本群\n" : " 被管理员<{$v[operate]}>T出过被群\n");
			}

			$this->message = $this->message . $mess;

		}
	}

	private function __get($property_name) {
		return $this-> $property_name;
	}

	private function __set($property_name, $value) {
		$this->$property_name = $value;
	}
}
?>